package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.CategoryPageQueryDTO;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Category;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 分类 持久层
 */
@Mapper
public interface CategoryMapper {

    /**
     * 根据类型查询分类
     * @param type
     * @return
     */
    List<Category> findCategoryByType(Integer type);

    /**
     * 分页查询
     * @param categoryPageQueryDTO
     * @return
     */
    Page<Category> findCategoryByName(CategoryPageQueryDTO categoryPageQueryDTO);

    /**
     * 添加分类
     * @param category
     */
    void insert(Category category);

    @Delete("delete from category where id = #{id}")
    void deleteById(Long id);

    /**
     * 修改分类
     * @param category
     */
    void update(Category category);

    /**
     * 修改分类状态
     * @param status
     * @param id
     */
    @Update("update category set status = #{status} where id = #{id}")
    void updateStatusById(Integer status, Long id);

}
